<?php

namespace App\Traits\Relation;

use App\Models\User;
use App\Models\Genre;
use App\Models\Project;
use App\Models\Company;
use App\Models\Schedule;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

trait AttendanceRelation
{
	/**
	 * 获取考勤记录的所属公司信息
	 *
	 * Date: 10/05/2018
	 * @author George
	 * @return mixed
	 */
	public function company()
	{
		return $this->belongsTo(Company::class, 'company_id', 'id');
	}

	/**
	 * 获取考勤关联的项目信息
	 *
	 * Date: 30/04/2018
	 * @author George
	 * @return BelongsTo
	 */
	public function project()
	{
		return $this->belongsTo(Project::class, 'project_id', 'id');
	}

    /**
     * 获取排班类型
     *
     * Date: 23/04/2018
     * @author George
     * @return mixed
     */
    public function genre()
    {
        return $this->hasOne(Genre::class, 'id', 'genre_id');
    }

    /**
     * 获取考勤的排班记录
     *
     * Date: 23/04/2018
     * @author George
     * @return mixed
     */
    public function schedule()
    {
        return $this->hasOne(Schedule::class, 'id', 'schedule_id');
    }

	/**
	 * 获取考勤的用户信息
	 *
	 * Date: 30/04/2018
	 * @author George
	 * @return BelongsTo
	 */
	public function user()
	{
		return $this->belongsTo(User::class, 'user_id', 'id');
    }
}
